#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main()
{
    char *str = "hello Linux";
//    *str = 'H'; //字符常量区不可被修改，为什么？？？ 曾经又是怎么被加载的？

    return 0;
}


//int g_val = 100;
////
////int main()
////{
////    pid_t id = fork();
////    if(id == 0)
////    {
////        //child
////        int cnt = 5;
////        while(1)
////        {
////            printf("child, Pid: %d, Ppid: %d, g_val: %d, &g_val=%p\n", getpid(), getppid(), g_val, &g_val);
////            sleep(1);
////            if(cnt == 0)
////            {
////                g_val=200;
////                printf("child change g_val: 100->200\n");
////            }
////            cnt--;
////        }
////    }
////    else
////    {
////        //father
////        while(1)
////        {
////            printf("father, Pid: %d, Ppid: %d, g_val: %d, &g_val=%p\n", getpid(), getppid(), g_val, &g_val);
////            sleep(1);
////        }
////    }
////
////    sleep(100);
////    return 0;
////}
////
////
////
//////int un_gval;
//////int init_gval=100;
//////
//////struct s
//////{
//////    int a;
//////    int b;
//////    int c;
//////};
//////
//////int main(int argc, char *argv[], char *env[])
//////{
//////    printf("code addr: %p\n", main);
//////    char *str = "hello Linux";
//////
//////    printf("read only char addr: %p\n", str);
//////    printf("init global value addr: %p\n", &init_gval);
//////    printf("uninit global value addr: %p\n", &un_gval);
//////
//////    char *heap1 = (char*)malloc(100);
//////    char *heap2 = (char*)malloc(100);
//////    char *heap3 = (char*)malloc(100);
//////    char *heap4 = (char*)malloc(100);
//////    static int a = 0;
//////    printf("heap1 addr : %p\n", heap1);
//////    printf("heap2 addr : %p\n", heap2);
//////    printf("heap3 addr : %p\n", heap3);
//////    printf("heap4 addr : %p\n", heap4);
//////
//////    printf("stack addr : %p\n", &str);
//////    printf("stack addr : %p\n", &heap1);
//////    printf("stack addr : %p\n", &heap2);
//////    printf("stack addr : %p\n", &heap3);
//////    printf("stack addr : %p\n", &heap4);
//////    printf("a addr : %p\n", &a);
//////
//////    int i= 0;
//////    for(; argv[i]; i++)
//////    {
//////        printf("argv[%d]: %p\n",i, argv[i]);
//////    }
//////
//////    for(i=0; env[i]; i++)
//////    {
//////        printf("env[%d]: %p\n", i, env[i]);
//////    }
//////    return 0;
//////}
//////
//////
//////
//////
//////
//////
//////
//////
//////
//////
//////
//////
//////#include <stdio.h>
//////#include <stdlib.h>
//////#include <string.h>
//////#include <sys/types.h>
//////#include <unistd.h>
//////
////////int main(int argc, char *argv[], char *env[])
//////int main()
//////{
//////    printf("OUR_ENV: %s\n", getenv("OUR_ENV"));
//////    //pid_t id = fork();
//////    //if(id == 0)
//////    //{
//////    //    // child
//////    //    extern char **environ;
//////    //    int i = 0;
//////    //    for(; environ[i]; i++)
//////    //    {
//////    //        printf("%d: %s\n", i, environ[i]);
//////    //    }
//////    //}
//////    //sleep(3);
//////
////////    int i = 0;
////////    for(; env[i]; i++)
////////    {
////////        printf("pid: %d, env[%d]: %s\n", getpid(), i, env[i]);
////////    }
////// //   char *who = getenv("USER");
//////
////// //   if(strcmp(who, "root") != 0)
////// //   {
////// //       printf("%s,是一个非法用户\n", who);
////// //       return 1;
////// //   }
//////
////// //   printf("myself command!\n");
////// //   printf("myself command!\n");
////// //   printf("myself command!\n");
////// //   printf("myself command!\n");
////// //   printf("myself command!\n");
//////
//////    //if(argc != 2) 
//////    //{
//////    //    printf("touch: missing file operand\n");
//////    //    return 1;
//////    //}
//////
//////    //FILE *fp = fopen(argv[1], "w");
//////    //if(fp != NULL) fclose(fp);
//////
////////    if(argc != 4)
////////    {
////////        printf("Use error\nUsage: %s op[-add|sub|mul|div] d1 d2\n", argv[0]); //argv[0], 会不会不存在呢？？
////////        return 1;
////////    }
////////    int x = atoi(argv[2]);
////////    int y = atoi(argv[3]);
////////    int result = 0;
////////    // 你的程序一定有4个命令行参数，第一个是程序名
////////    if(strcmp(argv[1], "-add") == 0)
////////    {
////////        result = x + y;
////////        printf("%d+%d=%d\n", x, y, result);
////////    }
////////    else if(strcmp(argv[1], "-sub") == 0)
////////    {
////////        result = x - y;
////////        printf("%d-%d=%d\n", x, y, result);
////////    }
////////    else if(strcmp(argv[1], "-mul") == 0)
////////    {
////////        result = x * y;
////////        printf("%d*%d=%d\n", x, y, result);
////////    }
////////    else if(strcmp(argv[1], "-div") == 0)
////////    {
////////        if( 0 == y ) printf("%d/%d=error! div zero\n", x, y);
////////        else printf("%d/%d=%d\n", x, y, x/y);
////////    }
////////    else
////////    {
////////        printf("Use error, you should use right command line\nUsage: %s op[-add|sub|mul|div] d1 d2\n", argv[0]); //argv[0], 会不会不存在呢？？
////////    }
////////
//////
//////    //int i = 0;
//////    //for(; i < argc; i++ )
//////    //{
//////    //    printf("%d: %s\n", i, argv[i]);
//////    //}
//////
//////    //printf("hello world!\n");
//////    return 0;
//////}
//
